import pytest

from common.Base_request import Base_request
from common.yaml_tools import YamlTools
from yige.requests_test import CommonApi


logindata = YamlTools.read_yaml_file("api_login.yaml")[0]
print(logindata)

class TestLogin:
    @pytest.mark.parametrize("login_data",logindata["parametrize"])
    # def test_login(self):
    #     result=CommonApi.demo3("admin","123456")
    #     assert result =="success","登录成功"
    def testlogin(self,login_data):
        result = CommonApi.demo3(login_data["data"]["userName"],login_data["data"]["password"])
        assert result == login_data["expect"],"登录失败"

    @pytest.mark.parametrize("login_data", logindata["parametrize"])
    def test_ALL(self, login_data):
        result = Base_request.excute_api_request(request=logindata["request"], testcase=login_data)
        assert result["message"] == login_data["expect"],"登录失败"